On the quantum circuit implementation of modus ponens

The process of inference reflects the structure of propositions with assigned truth values, either true or false. Modus ponens is a fundamental form of inference that involves affirming the antecedent to affirm the consequent. Inspired by the quantum computer, the superposition of true and false is used for the parallel processing. In this work, we propose a quantum version of modus ponens. Additionally, we introduce two generations of quantum modus ponens: quantum modus ponens inference chain and multidimensional quantum modus ponens. Finally, a simple implementation of quantum modus ponens on the OriginQ quantum computing cloud platform is demonstrated.


On the quantum circuit implementation of modus ponens Songsong Dai
The process of inference reflects the structure of propositions with assigned truth values, either true or false.Modus ponens is a fundamental form of inference that involves affirming the antecedent to affirm the consequent.Inspired by the quantum computer, the superposition of true and false is used for the parallel processing.In this work, we propose a quantum version of modus ponens.Additionally, we introduce two generations of quantum modus ponens: quantum modus ponens inference chain and multidimensional quantum modus ponens.Finally, a simple implementation of quantum modus ponens on the OriginQ quantum computing cloud platform is demonstrated.
The term "quantum" is spreading continuously in interdisciplinary scientific literature.Studying the quantum counterparts of existing classical models is an inspiration for technological advancement 1-8 .Inference is omnipresent, appearing in physics, mathematics, and daily life.The basic rule of classical inference model is the modus ponens (see Fig. 1a): if p is true and p implies q, then q is true.For example, if p represents "The cat is alive" and q represents "The mouse is dead, " then p is true and the implication p ⇒ q holds, it follows that "The mouse is dead".
When it comes to quantum world, however, Schrödinger's cat is simultaneously alive and dead.Then, is the mouse alive or dead?Typically, we know that the rule remains unchanged, then, in some sense, we may infer that "the mouse is also simultaneously alive and dead" from the new premiss.However, this inference is visibly somewhat arbitrary and lacks justification.In this work, we introduce the quantum modus ponens (QMP) which comes from the consideration of the quantum counterpart of modus ponens in classical logics.As sketched in Fig. 1b, our QMP inference form has a quantum premiss and a quantum rule which includes a quantum rule antecedent and a rule consequent.The word "quantum" in the QMP refers to the quantization of true values of propositions.In classical MP, every proposition is assigned a definite truth value, either 'true' or 'false' .Truthvalue assignment in QMP is assigned a qubit.The superposition state a 0 |0� + a 1 |1� represents a proposition that involves of a certain degree of uncertainly.According to quantum probability, |a 1 | 2 stands for the probability of the proposition being false, while |a 0 | 2 represents the probability of the proposition being true.This is denoted as P(|ψ�) = |a 1 | 2 for any |ψ� = a 0 |0� + a 1 |1�.

Principle and circuit of QMP
In Classical MP, q = p ∧ (p → q) which states that if p is true and p implies q, then q is true.We extended this to QMP using quantum probability, which asserts that the probability of the conclusion being true is equal to the probability of the premiss being true multiplied by the probability of the rule being true.
First, consider the rule "IF p is |a� , then q is |b� ".What is the probability of this rule being true?In classical logic, p → q = 1 contains three cases: p = q = 1 , p = q = 0 , and p = 0 and q = 1 .In this sense, the probability of the rule being true calculated as follows, We introduce a quantum circuit that utilizes the NOT and AND gates to derive the rule's result (see Fig. 2a and  b), with the AND gate being obtained through the Toffoli gate.The quantum cost of Fig. 2c is 5 since the quantum cost of a Toffoli gate is 5 9 .
We then consider the conclusion derived from this rule and the premise "p is |c� ", which is true only if both the rule and the premise are true.In this sense, the probability of the conclusion being true calculated as follows, Clearly, we have the following property

Generalization to a chain of inferences
The quantum analogy of the chain of inferences is an intriguing extension of MP inference.It involves a sequence of logical deductions: if p 1 is true and p 1 implies p 2 , up to the point where p n−1 implies p n , then p n is also true.This can be formally expressed as We will now delve into the quantum counterpart of this chain of inferences (see Fig. 3a).
The conclusion " p n is |c n � " is derived from the initial premise " p 1 is |c 1 � " and n − 1 rules p i → p i+1 ( i = 1, ..., n − 1 ), which holds true only when all rules and the initial premise are true.Therefore, the probability of the conclusion being true can be calculated as follows: Clearly, we have the following property This property implies that as more rules are applied, the likelihood of the conclusion being true decreases.Now we present a quantum circuit to implement the chain of QMP inferences (see Fig.

Generalization to n premises, one conclusion
Another fascinating generalization of modus ponens is multidimensional modus ponens.This concept posits that if propositions p 1 , • • • , p n are true and it holds that p 1 , • • • , p n imply q, then q is true.Formally, this gener- alization can be expressed as (4)  www.nature.com/scientificreports/Delving into the quantum counterpart of this notion is our next focus, and you can find a visual representation in Fig. 4a.The conclusion "q is |d� " is derived from the n premises " x 1 is |c 1 � , ... , x n is |c n � " and one rule with n antecedents and one consequent "IF x 1 is |a 1 �, ... , x n is |a n � , then y is |b� ".The conclusion is true only when all premises and the rule are true.Therefore, the probability of the conclusion being true can be calculated as follows: Clearly, we have the following property As a corollary, we have P(|d�) ≤ P(|c i �) for each i = 1, ..., n .We see that the more premises we use, the less likely the conclusion is to be true.Now we present a quantum circuit to implement the multidimensional modus ponens (see Fig. 4b) with two NOT gates, and two (n + 2)-qubit Toffoli gates.The quantum cost of a (n + 1)-qubit Toffoli gate is 32n-120 10 , then quantum cost of Fig. 3b is 64n-176.

A sample quantum computer implementation
Let us consider the example in the Introduction section, the rule is "If the cat is alive, then the mouse is dead, " and the premise is that "The cat is simultaneously alive and dead." So what is the conclusion?To represent the truth of the rule's antecedent, we denote |1� .Similarly, we use |1� to signify the truth of the rule's consequent.Furthermore, the premise being simultaneously true and false is symbolized by www.nature.com/scientificreports/This implementation is executed using the OriginQ quantum computing cloud platform 11 .Additionally, the quantum circuit for this example is depicted in Fig. 5a.The initial state is |0�|0�|0�|0�|0� .Firstly, by using NOT gate on q[0] and q [2], and Hadamard gate on q [3], then the initial state is converted to |1�|0�|1� |0�+|1� √ 2 |0� .Sec- ondly, a Toffili gate is used on q[0], q[1] and q [2] and the quantum state is still |1�|0�|1� |0�+|1� √ 2 |0� .Here q[0] and q[1] represent the states of antecedent and consequent of the rule, respectively.And then the output of q [2] is result of the rule.Thirdly, a Toffili gate is used on q [2], q [3] and q [4], and the quantum state becomes . Here the input of q [3] is state of the premiss and the output of q [4] is state of the conclusion.In a perfect scenario, the conclusion "the mouse is dead" is |0�+|1� √ 2 , i.e., simultaneously true and false.The process further involves measuring the 5th qubit of the output.The result of executing the program of Fig. 5a on  Our circuit is about the quantum modus ponens with the rule "IF p is |1� , then q is |0� " and the premiss " p is |0�+|1� √ 2 ".(b) The output is [0.506875, 0.493125], indicating that the probability of q being false is 0.506875, while the probability of q being true is 0.493125.
OriginQ quantum platform is shown in Fig. 5b.As it can be seen, the probability of the state being |0� after the measurement is 0.506875, while the probability of the state being |1� is 0.493125, note that the number of repeated tests is 8000.

Discussion
As mentioned by Feynman 2 , quantum mechanical systems are better simulated by quantum computers than classical computers.In this perspective, reasoning with quantum data can be achieved using quantum inference, which involves collections of rules capable of mapping quantum inputs to quantum outputs.The goal achieved by this research is the proof of the quantum computers feasibility in performing inference involving quantum premises and quantum conclusions.This research initiates the extension of MP inference to the quantum scenario, and formalizes the MP inference chain and multidimensional MP inference accordingly, providing quantum circuits as well.There is still much research to be done, particularly in the applications of IF-Then rules.For example, utilizing a large set of IF-Then rules to build a quantum inference system and applying it to pattern recognition and decision making.

OPEN
School of Electronics and Information Engineering, Taizhou University, Taizhou 318000, Zhejiang, China.email: ssdai@tzc.edu.cnVol:.(1234567890)Scientific Reports | (2024) 14:14245 | https://doi.org/10.1038/s41598-024-65224-9www.nature.com/scientificreports/This property implies that the probability of the conclusion being true cannot be greater than the probability of the premise being true.Now, we present a quantum circuit to implement QMP (see Fig.2d) with 2 NOT gates and 2 Toffoli gate.The quantum cost of Fig.2dis 10.It can also be used to simulate classical modus ponens inference.
3b) with 2n − 2 NOT gates, and 2n − 2 Toffoli gates.The quantum cost of Fig. 3b is 10n-10.It provides all the intermediate conclusions and the truth values for each rule.

Figure 1 .
Figure 1.From modus ponens to quantum modus ponens.(a) Form of modus ponens.(b)The architectire exhibition of quantum modus ponens.The rule consists of an antecedent "p is |a� " and a consequent "q is |b�".

Figure 2 .
Figure 2. Quantum circuits of rule and quantum modus ponens.The circuit implementation is based on the NOT (a) and AND (b) gates.First, we calculate the true value of the rule (c) and then determine the inference's conclusion (d).

Figure 3 .
Figure 3. Form and circuit of a chain of inference.(a) A chain includes one premise and n − 1 rules.Each premise i and rule i deduce a conclusion i+1 , which then becomes the premise i+1 for the next inference.(b) The circuit diagram shows how to implement the inference chain using 4n − 3 qubits, 2n − 2 NOT gates, and 2n − 2 Toffoli gates.

Figure 4 .
Figure 4. General form and circuit of multidimensional quantum modus ponens.(a) One conclusion can be inferred from n premises and one rule that includes n antecedents and one consequent.(b) The circuit diagram shows how to implement the inference chain using 4n − 3 qubits, 2n − 2 NOT gates, and 2n − 2 Toffoli gates.The circuit diagram shows how to implement the multidimensional quantum modus ponens using 2n + 3 qubits, two NOT gates, and two (n + 2)-qubit Toffoli gates.

Figure 5 .
Figure 5.An example of quantum modus ponens.(a) Our circuit is about the quantum modus ponens with the rule "IF p is |1� , then q is |0� " and the premiss " p is |0�+|1� √